# # 训练过程需要构建损失函数（mse）
# # mse = f(w) 
# # w 是k1到kn······
# # 1.随机初始化k1···kn+1
# # 2.求mse对k1到kn+1的偏导
# # 3.以下做1000次
#     # 用k1 - k1的偏导······
#     # 用k2 - k2的偏导······
#     # 用kn - kn+1的偏导······
# # 4.就能够获得最小的mse，最终可以获得k1···kn+1
# # 5.代码开始


# import numpy as np
# import random as r

# # 定义函数，并导入X_train,y_train
# def fit(X_train,y_train):
#     X_train = np.array(X_train)             # 格式转换
#     y_train = np.array(y_train)             # 格式转换

#     # X矩阵补一列（方便矩阵乘）

#     k1 = np.random.randint(-100,100)
#     k2 = np.random.randint(-100,100)
#     k3 = np.random.randint(-100,100)
#     k4 = np.random.randint(-100,100)
#     k5 = np.random.randint(-100,100)

#     # 求偏导
#         # w是由k1···k5组成的向量
#     dk1 = 2 / X_train.shape[0] * ((X_train @ w) - y_train).T @ X_train[:,0]
#     dk2 = 2 / X_train.shape[0] * ((X_train @ w) - y_train).T @ X_train[:,1] 
#     dk3 = 2 / X_train.shape[0] * ((X_train @ w) - y_train).T @ X_train[:,2] 
#     dk4 = 2 / X_train.shape[0] * ((X_train @ w) - y_train).T @ X_train[:,3] 
#     dk5 = 2 / X_train.shape[0] * ((X_train @ w) - y_train).T @ X_train[:,4] 
